package com.jike.jkgame;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TabHost;
import android.widget.TextView;

public class FriendsFragment extends Fragment {
	private TabHost mTabHost;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.friends_layout, container, false);

		mTabHost = (TabHost) v.findViewById(android.R.id.tabhost);
		mTabHost.setup();
		mTabHost.addTab(mTabHost.newTabSpec("list").setIndicator("好友")
				.setContent(R.id.list_friends));
		mTabHost.addTab(mTabHost.newTabSpec("add").setIndicator("加好友")
				.setContent(R.id.add_friends));
		setTabHeight(50);
		mTabHost.setCurrentTab(1);
		mTabHost.setCurrentTab(0);
		return v;
	}

	private View createTabView(Context context, String tag) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.tab_indicator_layout, null);
		TextView tv = (TextView) view.findViewById(R.id.tabLabel);
		tv.setText(tag);
		return view;
	}

	public void setTabHeight(int height) {
		for (int i = 0; i < mTabHost.getTabWidget().getTabCount(); i++) {
			TextView view = (TextView) mTabHost.getTabWidget().getChildAt(i)
					.findViewById(android.R.id.title);
			// 16908310
			view.getLayoutParams().height = (int) (height * this.getResources()
					.getDisplayMetrics().density);
			view.setTextSize(18);
		}
	}

}
